<!doctype html>
<html>
    <head>
        <meta charset="UTF-8"/>
        <title>品类管理</title>
	    <link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
	    <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
        <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
        <script src='https://cdn.bootcss.com/jquery.form/4.2.2/jquery.form.min.js'></script> <!--上传需要引入的包-->
        <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="/webapp/js/lib/jquery.global.settings.js"></script>
	    <script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
	    <script type="text/javascript" src="/webapp/js/common/config.js"></script>
    </head>
    <body>
       <div class="easyui-container-fluid">
          <div class="easyui-panel" style="border: none;">
            <div class="nav" id="nav"></div> 
            <div class="easyui-panel" style="border:none;">
              <form id="ff">
                <div style="margin-bottom:20px">
                  <label class="item-label">代码：</label>
                  <input class="easyui-textbox" style="width:100px;" type="text" name="code"  />
                  <label class="item-label">名称：</label>
                  <input class="easyui-textbox" style="width:100px;" type="text" name="name"  />
                  <label class="item-label">状态：</label>
                    <input id="entityStatus" class="easyui-switchbutton" checked style="width:80px;height:30px;" onText="启用" offText="禁用"  >
                  <label class="item-label">匹配字：</label>
                  <input class="easyui-textbox" style="width:100px;" type="text" name="matchWords"  />
                  <label class="item-label">禁用字：</label>
                  <input class="easyui-textbox" style="width:100px;" type="text" name="disableWords"  />
                  <a href="javascript:void(0);" class="easyui-linkbutton c8" style="width:80px;margin-left: 40px;" onclick="searchBy()">查询</a>
                </div>
              </form>
                <div id="upmall" class="easyui-window upload-wrapper" title="上传文件" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:400px;height:260px;padding:10px;">
                    <form id="file_form" action="" enctype="multipart/form-data"method="post">
                        <div style="margin-bottom:20px;margin-top: 20px;">
                            <input type="file" multiple="multiple" name="file" id="file_input" class="item-label"style="margin-top: 33px;margin-left: 64px;width: 280px;" />
                        </div>
                        <div style="margin-bottom:20px;margin-top: 60px;text-align:center">
                            <input type="button" value="文件上传" name="Submit" id='sub' style="height: 40px;width: 100px;font-size: 18px;" class="easyui-linkbutton c8">
                        </div>
                    </form>
                </div>
                <div id="displayxx" class="easyui-window upload-wrapper" title="上传结果" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:500px;height: 300px;padding:10px;">
                    <div><li>信息为：</li><span id="messagetext"></span></div>
                    <div style="margin-left: 180px; margin-top: 100px"><button class="easyui-linkbutton c8" style="width: 100px;" onclick="clickHandler()">确定</button></div>
                </div>

                <div id="cpUpload" class="easyui-window upload-wrapper" title="上传文件" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:400px;height:260px;padding:10px;">
                    <form id="file_formCp" action="" enctype="multipart/form-data"method="post">
                        <div style="margin-bottom:20px;margin-top: 20px;">
                            <input type="file" multiple="multiple" name="file" id="file_inputCp" class="item-label"style="margin-top: 33px;margin-left: 64px;width: 280px;" />
                        </div>
                        <div style="margin-bottom:20px;margin-top: 60px;text-align:center">
                            <input type="button" value="文件上传" name="Submit" id='subCp' style="height: 40px;width: 100px;font-size: 18px;" class="easyui-linkbutton c8">
                        </div>
                    </form>
                </div>
            </div>
            <div class="table-wrapper">
             <table id="datagrid" data-options="fitColumns:true,scrollbarSize:0">
               <thead>
                 <tr>
                   <th data-options="field:'code',align:'center'" width="100">代码</th>
                   <th data-options="field:'name',align:'center'" width="100">名称</th>
                   <th data-options="field:'matchWords',align:'center'" width="200">匹配字</th>
                   <th data-options="field:'disableWords',align:'center'" width="200">禁用字</th>
                   <th data-options="field:'tmDisable',align:'center'" width="200">禁用字(天猫)</th>
                   <th data-options="field:'require',align:'center'" width="100">负责人</th>
                   <th data-options="field:'entityStatus',align:'center',formatter:statusFormatter" width="50">状态</th>
                   <th data-options="field:'action',formatter:actions,align:'center'" width="180">操作</th>
                 </tr>
               </thead>
               <tbody>
               </tbody>
             </table>
           </div>
          </div> 
       </div>
    </body>
    <script type="text/javascript">
           $(function(){
               var height = $(window).height();
               var nav_height = $("#nav").outerHeight();
               var ff_height = $("#ff").outerHeight();
               var table_height = height-nav_height-ff_height-40;
               $("#datagrid").css("max-height",table_height);
               $("#datagrid").datagrid({
                   toolbar:[{
                        text:"添加品类",
                        handler:function(){
                          	window.parent.addTab("添加品类","/webapp/pages/product/category/add.html");
                        }
                      },'-',{
                       text:'上传特殊品牌',
                       handler:function(){
                           $("#upmall").window("open");
                       }
                   },'-',{
                       text:'上传最大量最小价',
                       handler:function(){
                           $("#cpUpload").window("open");
                       }
                   }]
               });
               aRecords("品类管理","/webapp/pages/product/category")
           });
           function manageCategoryMetadata(categoryCode){
        	   window.parent.addTab("品类元数据管理","/webapp/pages/product/categoryMetadata/list.html?categoryCode="+categoryCode);
           }
           $("#ff").keydown(function (event) {
               var e = event || window.event;
               var keyCode = e.keyCode || e.which;
               if(keyCode=="13"){
                   searchBy();
               }
           });
           /*上传文件from的方式*/
           $(function() {
               $("#sub").click(function () {
                   // var form = new FormData(document.getElementById("file_form"));
                   // alert(form);
                   $("#file_form").ajaxSubmit({
                       xhrFields:{withCredentials:true},
                       url:config.url +"/category/categoryUpload",
                       type:"POST",
                       dataType : "json",
                       data:$('#file_form').serialize(),
                       processData: false,
                       beforeSend:function () {
                           $.messager.progress({
                               title:"请稍等",
                               interval:20,
                               text:"操作进行中..."
                           });
                       },
                       complete:function () {
                           $.messager.progress("close");
                       },
                       success : function(data) {
                           if(data.code=="200"){
                               $("#displayxx").window("open");
                               document.getElementById("messagetext").innerText=data.msg;
                               // alert(data.msg);
                           }else{
                               $("#displayxx").window("open");
                               document.getElementById("messagetext").innerText=data.msg;
                           }
                       }
                   })
               })
               $("#subCp").click(function () {
                   $("#file_formCp").ajaxSubmit({
                       xhrFields:{withCredentials:true},
                       url:config.url +"/category/cpUpload",
                       type:"POST",
                       dataType : "json",
                       data:$('#file_formCp').serialize(),
                       processData: false,
                       beforeSend:function () {
                           $.messager.progress({
                               title:"请稍等",
                               interval:20,
                               text:"操作进行中..."
                           });
                       },
                       complete:function () {
                           $.messager.progress("close");
                       },
                       success : function(data) {
                           if(data.code=="200"){
                               $("#displayxx").window("open");
                               document.getElementById("messagetext").innerText=data.msg;
                               // alert(data.msg);
                           }else{
                               $("#displayxx").window("open");
                               document.getElementById("messagetext").innerText=data.msg;
                           }
                       }
                   })
               })
           });
           function clickHandler() {
               // alert("onclick attribute in html");
               $("#displayxx").window("close");
               $("#upmall").window("close");
               $("#cpUpload").window("close");
           }
      </script>
      <script type="text/javascript" src="/webapp/js/common/pagelist.js"></script>
      <script type="text/javascript">
          function actions(val,row){
              var disableBtnText = row.entityStatus=='OK'?'禁用':"启用";
              return "<a href='javascript:void(0);' class='easyui-linkbutton l-btn l-btn-small' "+
                  "style='width:90px;' onclick='manageCategoryMetadata(\""+row.code+"\")'>管理元数据</a>&nbsp;&nbsp;"+
                  "<a href='javascript:void(0);' class='easyui-linkbutton l-btn l-btn-small' "+
                  "style='width:60px;' onclick='edit(\""+row.id+"\")'>修改</a>&nbsp;&nbsp;"+
                  "<a href='javascript:void(0);' class='easyui-linkbutton l-btn l-btn-small' style='width:60px;' onclick='updateStatus(\""+row.id+"\", \"" + row.entityStatus + "\")'>"+disableBtnText+"</a>";
          }
          function edit(id) {
              window.parent.addTab("修改品类","/webapp/pages/product/category/add.html?id="+id);
          }
      </script>
</html>
